//
//  XTMyLoginColorViewController.m
//  BeautifulHome
//
//  Created by dlios on 15-5-19.
//  Copyright (c) 2015年 ACE. All rights reserved.
//

#import "XTMyLoginColorViewController.h"
#import "UIColor+AddColor.h"

@interface XTMyLoginColorViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSArray *arr;
@property (nonatomic, retain) NSMutableArray *mArr;

@end

@implementation XTMyLoginColorViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.arr = @[@"中国红" ,@"活力橙", @"蛋挞黄", @"青草绿" , @"碧湖青", @"天空蓝", @"魅力紫", @"经典黑", @"经典白"];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageView.image = [UIImage imageNamed:@"999b"];
    [self.view addSubview:imageView];
    UILabel *myTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width ,44)];
    myTitle.text = @"主题";
    myTitle.textAlignment = 1;
    [self.view addSubview:myTitle];
    self.mArr = [@[@"111", @"222", @"333", @"444", @"555", @"666", @"777", @"888", @"999"]mutableCopy];
    [self createTableView];
}
- (void)createTableView
{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height - 113) style:UITableViewStyleGrouped];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_tableView];
    [_tableView release];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 9;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *reuse = @"reuse";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse] autorelease];
    }
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.text = _arr[indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 创建通知中心单例
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    // 发送通知
    // 参数1: 通知名
    // 参数2: 发送通知时 可传递的一个参数
    // 参数3: 多个参数可以拼接成一个字典进行发送
    NSString *str = self.mArr[indexPath.row];
    [center postNotificationName:@"color" object:str userInfo:@{@"lol": @"666"}];
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
- (void)creatNotificationCenter
{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(changeColor:) name:@"color" object:nil];
}
- (void)changeColor:(NSNotification *)noti
{
    self.navigationController.navigationBar.translucent = NO;
    self.backgroundColor = noti.object;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:self.backgroundColor] forBarMetrics:UIBarMetricsDefault];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
